#include "qanimImpl.h"
//
QanimImpl::QanimImpl( QWidget * parent, Qt::WFlags f) 
	: QDialog(parent, f)
{
	setupUi(this);
	setWindowFlags(Qt::FramelessWindowHint);
	adjustWindow();
	height = 0;
	freq = 0;
	rect = this->geometry();	
	opac = this->windowOpacity();
	//QMessageBox::warning(this, tr("My Application"),QString::number(opac),QMessageBox::Ok);
	opac = 0.0;
	//this->setWindowOpacity(opac); 
	//opac = this->windowOpacity();
	//QMessageBox::warning(this, tr("My Application"),QString::number(opac),QMessageBox::Ok);
	time = new QTime(0,0,0,0);
    timer = new QTimer(this);
    this->setGeometry(screenWidth,screenHeight,362, 0);
   	connect(timer, SIGNAL(timeout()), this, SLOT(showTime()));
    start_stop();    
}

void QanimImpl::start_stop()
{
	time->start();
	timer->start(100);
}
 
void QanimImpl::showTime()
{
	QTime zeroTime;
    int ms = time->elapsed();
    if(ms>=1){// 5 MINNUTE    	
    	freq ++;    	 
    	if (freq < 7){
    		height += 11;  
    		//QMessageBox::warning(this, tr("My Application"),QString::number(opac),QMessageBox::Ok);
    		this->setGeometry(screenWidth,screenHeight,362, height);
        	time->restart();
   		}
   		else if (freq > 20 && freq < 27){
   			height -= 11;  
    		this->setGeometry(screenWidth,screenHeight,362, height);
        	time->restart();
   		}
   		else if(freq >= 27) {
   			//QMessageBox::warning(this, tr("My Application"),QString::number(this->windowOpacity()),QMessageBox::Ok);
   			timer->stop();  
		}  	
    }
}

void QanimImpl::adjustWindow(){
	QDesktopWidget *desktop = QApplication::desktop();
	int width; 
	int height;
	int x, y;
	QSize windowSize;	 
	screenWidth = desktop->width(); // get width of screen
	screenHeight = desktop->height(); // get height of screen	 
	windowSize = size(); // size of our application window
	width = windowSize.width(); 
	height = windowSize.height();	 
	// little computations
	x = (screenWidth - width);
	y = (screenHeight - 0);
	//move (x, y);
	//QMessageBox::warning(this, tr("My Application"),QString::number(rect.y())+QString::number(y),QMessageBox::Ok);
}
//
